---
pagination: 
    data: apis.classes
    size: 1
    alias: api
permalink: "api/{{ api.name }}/"
layout: api.njk
---

{% macro meta(api, forFunc=false) -%}
    {% if forFunc %}
        <h3 id="{{ api.name }}">{{ api.name }}<a href="#{{ api.name }}">¶</a></h3>
    {% else %}
        <h1>{{api.name}}</h1>
    {% endif %}
    {% if api.augments | length %}
        <span>extends</span>
        {%- for augmentation in api.augments %}
            <a href="/api/{{ augmentation.type.name }}">{{ augmentation.type.name }}</a> {% if not loop.last %}, {% endif %}
        {% endfor -%}
    {% endif %}
    {%- for child in api.description.children %}

        {% if child.type == 'paragraph' %}
            <p>
                {%- for content in child.children %}
                    {% if content.type == 'text' %}
                        {{ content.value }}
                    {% endif %}
                    {% if content.type == 'html' %}
                        {{ content.value | safe }}
                    {% endif %}
                    {% if content.type == 'inlineCode' %}
                        <code>{{ content.value }}</code>
                    {% endif %}
                    {% if content.type == 'link' %}
                        {% if 'http' in content.url %}
                            <a href="{{ content.url }}">
                                {% if content.children[0].type == "inlineCode" %} 
                                    <code>{{ content.children[0].value }}</code>
                                {% else %}
                                    {{ content.children[0].value }}
                                {% endif %}
                            </a>
                        {% else %}
                            <a href="../{{ content.url }}">{{ content.url }}</a>
                        {% endif %}
                    {% endif %}
                {% endfor -%}
            </p>
        {% endif %}
    {% endfor -%}
{%- endmacro %}

{% macro func(fn) -%}
    {% if fn.examples | length %}
        <h5>Examples</h5>
        {%- for example in fn.examples %}
            <pre><code>{{ example.description }}</code></pre>
        {% endfor -%}
    {% endif %}

    <h5>Parameters</h5>
    {% if fn.params | length %}
        {%- for tag in fn.tags %}
            {% if tag.title == 'param' %}
            <hr/>
            <dl>
                <dt>
                    <code>{{ tag.name }}</code>
                    <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/{{ tag.type.name }}">
                        {{ tag.type.name }}
                    </a>
                </dt>
                <dd>
                    {{ tag.description | markdown | safe }}
                        {% if tag.default %}
                        <dl>
                            <dt><b>Default value</b></dt>
                            <dd><code>{{ tag.default }}</code></dd>
                        </dl>
                        {% endif %}
                </dd>
            </dl>
            {% endif %}
        {% endfor -%}
        <hr/>
    {% else%}
    <p>This API does not have any parameters</p>
    {% endif %}

    <h5>Returns</h5>
    {% if fn.returns | length %}
        {%- for tag in fn.tags %}
            {% if tag.title == 'returns' %}
                <p>{{ tag.description | markdown | safe }}</p>
                <p>
                    {% if tag.type.name == 'Promise' %}
                        <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/{{ tag.type.name }}">{{ tag.type.name }}</a>
                    {% elif tag.type.expression.name == 'Array' %}
                        <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>.<<a href="/api/{{ tag.type.applications[0].name }}">{{ tag.type.applications[0].name }}</a>>
                    {% else %}
                        <a href="/api/{{ tag.type.name }}">{{ tag.type.name }}</a>
                    {% endif %}
                </p>
            {% endif %}
        {% endfor -%}
    {% else%}
        <p>This API does not return any values</p>
    {% endif %}
{%- endmacro %}

{% macro listFuncs(fnList, category) -%}
    {% if fnList | length %}
        <h2>{{category}} Members</h2>
        {% for fn in fnList %}
            {{ meta(fn, true) }}
            {{ func(fn) }}
        <hr/>
        {% endfor %}
    {% endif %}
{%- endmacro %}

{{ meta(api) }}
{{ listFuncs(api.members.global, 'Global') }}
{{ listFuncs(api.members.inner, 'Inner') }}
{{ listFuncs(api.members.instance, 'Instance') }}
{{ listFuncs(api.members.events, 'Events') }}
{{ listFuncs(api.members.static, 'static') }}
